var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var common = require("./common");
var inTask = require("./inTask");
var Action = require("../../base/action");
var actionOneAcc = new Action("一键给手机加速", {
  execSCount: 0,
  execFCount: 0,
  maxExecSCount: 1, //最大成功执行次数
  maxExecFCount: 2, //最大失败执行次数
  maxTotalExecCount: 3, //最大总执行次数
  storage: common.storage,
});
actionOneAcc.exec = function () {
  var content = "一键给手机加速";
  var ocrItem = ocrGml.findTextOne(
    content,
    true,
    null,
    12,
    (device.height / 10) * 2
  );
  if (ocrItem) {
    utils.clickOcrItem(ocrItem);
    sleep(utils.getRandom(6, 8, 1000));
    back();
    sleep(utils.getRandom(2, 3, 1000));
    inTask.run();
    this.execSCount++;
    this.updateStorage();
  } else {
    this.execFCount++;
    this.updateStorage();
    console.log("没有找到" + content);
  }
};
module.exports = actionOneAcc;
